package com.mtsmda.questions;

import javax.management.RuntimeErrorException;

public class ForAndExceptions {
	static int countExceptions = 0; 
	static StringBuilder builder = new StringBuilder();
	public static void main(String[] args) {

		for (int i = 0; i < 10; i++) {
			try {
				isEven(i);
			} catch (Exception e) {
				++countExceptions;
				builder.append(countExceptions).append(" - ").append(e.getMessage()).append("\n");
			}
		}
		System.out.println("count exceptions = " + countExceptions);
		System.out.println(builder.toString());
		System.out.println("\n");
		
		int ar [] = {15, 158, 192};

	}

	private static boolean isEven(int i) throws EvenException {
		if (i % 2 != 0) {
			throw new EvenException("i % 2 != 0");
		}
		if(i % 5 != 0){
			throw new NullPointerException("i % 5 != 0");
		}
		return i % 2 == 0;
	}

}

class EvenException extends Exception {

	private static final long serialVersionUID = 1L;

	public EvenException() {

	}
	
	public EvenException(String message) {
		super(message);
	}

}